/**
 * Auto gen via dbpojo-gen.
 */
package com.us.usws.dao;

import java.util.List;

import net.iwsh.core.db.DBExecutor;
import net.iwsh.core.db.ext.DialectSyntaxParser;
import net.iwsh.core.db.ext.SQLWithParams;

import com.us.usws.model.domain.MeetingAttendee;
import com.us.usws.model.flat.DOMeetingAttendee;

/**
 * DAO class
 * @author robot
 */
public class MeetingAttendeeDAO {

	/**
	 * Query SQLs
	 */
	private static final String SQL_GET_TOTAL_COUNT = "select count(*) from hv_meeting_attendee";

	private static final String SQL_GET_ALL_MEETINGATTENDEES = "select * from hv_meeting_attendee";

	/**
	 * CUR SQLs
	 */
	private static final String SQL_INSERT_MEETINGATTENDEE = "insert into hv_meeting_attendee(meeting_uid,attendee_uid,seq_num,is_attended) values (?,?,?,?)";

	private static final String SQL_GET_MEETING_ATTENDEES_BY_MEETING_UID = "select * from hv_meeting_attendee where meeting_uid=? order by seq_num";

	/**
	 * DBExeutor
	 */
	private DBExecutor dbe = new DBExecutor();

	/**
	 * Get Count.
	 */
	public int getTotalCount() {
		return dbe.getCount(SQL_GET_TOTAL_COUNT);
	}

	/**
	 * Get all list.
	 */
	public List<MeetingAttendee> getAllMeetingAttendees() {
		return dbe.list(SQL_GET_ALL_MEETINGATTENDEES, MeetingAttendee.class);
	}

	/**
	 * Get all list by pagination.
	 */
	public List<MeetingAttendee> getMeetingAttendees(int start, int end) {
		SQLWithParams swp = DialectSyntaxParser.getParser().getPaginationSQLWithParams(SQL_GET_ALL_MEETINGATTENDEES, null, start, end);
		return dbe.list(swp.getSql(), MeetingAttendee.class, swp.getParams());
	}

	/**
	 * Insert one row.
	 */
	public String insertMeetingAttendee(DOMeetingAttendee meetingAttendee) {
		dbe.execute(SQL_INSERT_MEETINGATTENDEE, meetingAttendee.getMeetingUid(), meetingAttendee.getAttendeeUid(),
				meetingAttendee.getSeqNum(), meetingAttendee.getIsAttended());
		return meetingAttendee.getMeetingUid();
	}

	public List<MeetingAttendee> getMeetingAttendeesByMeeting(String meetingUid) {
		return dbe.list(SQL_GET_MEETING_ATTENDEES_BY_MEETING_UID, MeetingAttendee.class, meetingUid);
	}

}